<style>
    .btn {
        margin-left: 20px;
        margin-top: 20px;
    }

    .log_div {
        height: 500px;
        width: 97%;
        background-color: black;
        color: white;
        overflow-y: auto;
        margin-top: 20px;
    }

    .release_btn {
        background-color: yellow;
        color: red;
    }

    .release_btn:hover {
        background-color: #e0e83a;
        color: red;
    }

    .btn-success {
        background-color: green;
        color: black;
    }

    .btn-error {
        background-color: red;
        color: black;
    }
</style>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-body">
                    <div class="container-fluid">
                        <div class="row-fluid">
                            <span> 当前环境：</span>
                            <select ng-model="info.env_name" ng-change="init()">
                                <option ng-repeat="env in info.env" value="{{env}}">{{env}}</option>
                            </select>
                            <span style="color: red;padding-left: 5%;"
                                  ng-show="info.env_name == 'online' && !info.isAuthorize">生产环境需要授权后才能进行操作</span>
                            <br>
                            <br>
                            <div class="span12">
                                <div class="row">
                                    <div class="col-xs-12">
                                        <div class="box-body" style="margin-left: 18px;">
                                            <ul class="nav nav-tabs">
                                                <li class="" ng-repeat="zone in info.zones "
                                                    ng-if="zone.parent_code==null"
                                                    ng-class="{true:'active',false:''}[info.selectZone.zone_code==zone.zone_code]">
                                                    <a href="javascript:void(0)" data-toggle="tab"
                                                       ng-click="clickZone(zone)">
                                                        {{zone.zone_title}}
                                                    </a>
                                                </li>
                                            </ul>
                                            <button class="btn btn-info"
                                                    ng-class="{'success':'btn-success','error':'btn-error','common':''}[info.checkStatus]"
                                                    ng-click="check()">
                                                资源校验
                                            </button>
                                            <button class="btn btn-info"
                                                    ng-class="{'success':'btn-success','error':'btn-error','common':''}[info.gaStatus]"
                                                    ng-click="doSwitch('GA','A')">
                                                A组备用
                                            </button>
                                            <button class="btn btn-info release_btn" ng-click="gotoRelease()">
                                                去发版
                                            </button>
                                            <button class="btn btn-info"
                                                    ng-class="{'success':'btn-success','error':'btn-error','common':''}[info.ganStatus]"
                                                    ng-click="doSwitch('GNONE','A')">
                                                A组取消备用
                                            </button>
                                            <button class="btn btn-info"
                                                    ng-class="{'success':'btn-success','error':'btn-error','common':''}[info.gbStatus]"
                                                    ng-click="doSwitch('GB','B')">
                                                B组备用
                                            </button>
                                            <button class="btn btn-info release_btn" ng-click="gotoRelease()">
                                                去发版
                                            </button>
                                            <button class="btn btn-info"
                                                    ng-class="{'success':'btn-success','error':'btn-error','common':''}[info.gbnStatus]"
                                                    ng-click="doSwitch('GNONE','B')">
                                                B组取消备用
                                            </button>
                                            <div id="log_div" class="log_div">
                                                <log-div content="info.logHtml"></log-div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>


<script type="text/ng-template" id="autoShowError.html">
    <style type="text/css">
        .modal-content {
            width: 1100px;
            right: 250px;
        }
    </style>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header" style="margin-top:1px;">
                        <br>
                        <uib-accordion close-others="false">
                            <uib-accordion-group heading="" is-open="true">
                                <table class="table table-hover table-bordered">
                                    <thead>
                                    <tr>
                                        <th>
                                            名称
                                        </th>
                                        <th>
                                            类型
                                        </th>
                                        <th>
                                            ip
                                        </th>
                                        <th>
                                            端口
                                        </th>
                                        <th>
                                            jmx端口
                                        </th>
                                        <th>
                                            agent端口
                                        </th>
                                        <th>
                                            分组
                                        </th>
                                        <th>
                                            期望状态
                                        </th>
                                        <th>
                                            当前状态
                                        </th>
                                        <th>
                                            错误描述
                                        </th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr ng-repeat="x in info.appList|paging:page.index:page.size">
                                        <td>
                                            <span ng-show="x.app_name != undefined && x.app_name != null">
                                                {{x.app_name}}
                                            </span>
                                            <span ng-hide="x.app_name != undefined && x.app_name != null">
                                                {{x.type}}
                                            </span>
                                        </td>
                                        <td>
                                            <span ng-show="x.app_name != undefined && x.app_name != null">
                                                {{x.entrance_type}}
                                            </span>
                                            <span ng-hide="x.app_name != undefined && x.app_name != null">
                                                {{x.type}}
                                            </span>
                                        </td>
                                        <td>
                                            <span ng-show="x.app_name != undefined && x.app_name != null">
                                                {{x.host}}
                                            </span>
                                            <span ng-hide="x.app_name != undefined && x.app_name != null">
                                                <span ng-if="x.type == 'haproxy' || x.type == 'uschedule'">
                                                    {{x.hosts|split_filter:':':0}}
                                                </span>
                                                <span ng-show="x.type != 'haproxy' && x.type != 'uschedule'">
                                                    {{x.hosts}}
                                                </span>
                                            </span>
                                        </td>
                                        <td>
                                            <span ng-show="x.app_name != undefined && x.app_name != null">
                                                {{x.http_port}}
                                            </span>
                                            <span ng-hide="x.app_name != undefined && x.app_name != null">
                                                <span ng-if="x.type == 'haproxy'||x.type == 'uschedule'">
                                                    {{x.hosts|split_filter:':':1}}
                                                </span>
                                                <span ng-show="x.type != 'haproxy' && x.type != 'elb' && x.type != 'uschedule'">
                                                    {{x.hosts}}
                                                </span>
                                            </span>
                                        </td>
                                        <td>
                                            <span ng-show="x.app_name != undefined && x.app_name != null">
                                                {{x.jmx_port}}
                                            </span>
                                        </td>
                                        <td>
                                            <span ng-show="x.app_name != undefined && x.app_name != null">
                                                {{x.agent_port}}
                                            </span>
                                        </td>
                                        <td>
                                            {{x.group}}
                                        </td>
                                        <td>
                                            {{x.expect_status}}
                                        </td>
                                        <td>
                                            {{x.current_status}}
                                        </td>
                                        <td>
                                            <i ng-if="x.current_status == 'OUT_OF_SERVICE'"
                                               style="width: 40px;height: 15px;vertical-align:baseline; color: red;"
                                               class="glyphicon glyphicon-warning-sign ng-scope"
                                               uib-popover="当前应用出现异常，点击查看异常详情"
                                               popover-placement="left"
                                               popover-trigger="mouseenter"
                                               ng-click="selectError(x)"></i></td>
                                    </tr>
                                    </tbody>
                                </table>
                                <uib-pagination total-items="info.appList|filter:filter|size" ng-model="page.index"
                                                max-size="5"
                                                previous-text="上一页"
                                                next-text="下一页"
                                                first-text="首页"
                                                last-text="尾页"

                                                items-per-page="page.size"

                                                class="pagination-sm pull-right" boundary-links="true">

                                </uib-pagination>
                            </uib-accordion-group>
                        </uib-accordion>

                        <div class="modal-footer">
                            <button class="btn btn-warning" type="button" ng-click="cancel()">关闭</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</script>

<script type="text/ng-template" id="autoError.html">
    <style type="text/css">
        .modal-content {
            width: 1000px;
            right: 250px;
        }
    </style>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header" style="margin-top:1px;">
                        <br>
                        <uib-accordion close-others="false">
                            <uib-accordion-group heading="应用异常" is-open="true">
                                <textarea ng-disabled=true style="width: 930px;height: 360px;">{{info.msg}}
                                </textarea>
                            </uib-accordion-group>
                        </uib-accordion>
                        <div class="modal-footer">

                            <button class="btn btn-warning" type="button" ng-click="cancel()">关闭</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</script>